//
//  UPFirstActivityViewController.m
//  Uang Pasti
//
//  Created by 李永彬 on 2025/8/16.
//

#import "UPFirstActivityViewController.h"
#import "UPLoginViewController.h"
#import "UPActivityTopView.h"
#import "Circumibility.h"
#import "UPActivityProductListView.h"
#import "UPRepaymentCarouselView.h"
#import "UPAuthCompletedViewController.h"
#import "UPAuthViewController.h"
#import "UPContactViewController.h"
#import "UPPersonalViewController.h"
#import "UPYINHANGViewController.h"

@interface UPFirstActivityViewController ()<
UPActivityProductListViewDelegate,
UPActivityTopViewDelegate,
UPRepaymentCarouselViewDelegate>

@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UIImageView *bottomBgImageView;
@property (nonatomic, strong) UIImageView *chooseUsImgView;
@property (nonatomic, strong) UIImageView *handImgView;
@property (nonatomic, strong) UIImageView *quickLoanImgView;
@property (nonatomic, strong) UIButton *customerServiceBtn;
@property (nonatomic, assign) BOOL hasPresentLoginVC;
@property (nonatomic, strong) UPActivityTopView *activityTopView;
@property (nonatomic, strong) UPActivityProductListView *productListView;
@property (nonatomic, strong) Circumibility *topCircumibility;
@property (nonatomic, strong) Circumibility *repaymentCircumibility;
@property (nonatomic, strong) Circumibility *bannerProductCircumibility;
@property (nonatomic, strong) UPRepaymentCarouselView *repaymentView;

// 点击了got to lan按钮
@property (nonatomic, assign) BOOL isGoLoaning;

@end

@implementation UPFirstActivityViewController

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.hiddenTabBar = NO;
    self.hasPresentLoginVC = NO;
    self.bgImageView.image = [UIImage imageNamed:@"home_bgImage"];
    self.bgImageView.layer.contentsRect = CGRectMake(0, 0, 1, 0.716);
    self.activityTopView = [[UPActivityTopView alloc] init];
    self.activityTopView.delegate = self;
    [[UPKeychainManager sharedManager] saveString:getIDFVForKey() forKey: identifyVersionKey];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(handleLogOutOrExpiredAction:)
                                                 name: kLogOutOrExpiredNotificationKey
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(followUpMyOrderAction:)
                                                 name: kFollowUpMyOrderKey
                                               object:nil];

    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        // Fallback on earlier versions
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    
    [self commonInitSubviews];
    
    if ([UPUserDefaults boolForKey:homeReportGoogleMarketKey] == NO) {
        [UPUserDefaults setBool:YES forKey:homeReportGoogleMarketKey];
        [UPReportDataManager reportToGoogleMarket];
    }
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear: animated];
    [self.scrollView.mj_header beginRefreshing];
}

- (void)fetchData {
    [SVProgressHUD show];
    __block typeof(self) weakSelf = self;
    [UPStocksAPIManager fetchHomeInfomationWithCompletion:^(Lapidant * _Nullable model, NSString * _Nullable msg) {
        
        [self.scrollView.mj_header endRefreshing];
        if (model != nil) {
            __block BOOL isLarge = NO;
            __block Circumibility *foundCircumibility = nil;
            __block Circumibility *listCircumibility = nil;
            [model.circumibility enumerateObjectsUsingBlock:^(Circumibility *circumibility, NSUInteger idx, BOOL *stop) {
                NSString *tergmost = circumibility.tergmost;
                
                if ([tergmost isEqualToString:@"ilics"]) {
                    isLarge = YES;
                    foundCircumibility = circumibility;
                    *stop = YES; // 找到 ilics 就立即停止
                } else if ([tergmost isEqualToString:@"bucc"]) {
                    self.topCircumibility = circumibility;// banner
                } else if ([tergmost isEqualToString:@"axi"]) {
                    self.repaymentCircumibility = circumibility;
                } else if ([tergmost isEqualToString:@"singness"] && !foundCircumibility) {
                    foundCircumibility = circumibility; // 只记录第一个 singness
                } else if ([tergmost isEqualToString:@"religiousise"] && !listCircumibility) {
                    listCircumibility = circumibility; // 记录列表
                }
            }];
            
            self.bannerProductCircumibility = foundCircumibility;
            
            // 如果没有大卡位，处理列表
            if (!isLarge && listCircumibility) {
                weakSelf.productListView.productList = listCircumibility.leaderible;
            }

            // 处理topView
            if (foundCircumibility) {
                if (isLarge) {
                    [weakSelf setLargeCardLayout];
                } else {
                    [weakSelf setSmallCardLayout];
                }
                self.activityTopView.circumibility = foundCircumibility;
            }

            [weakSelf setRepaymentView];

            [SVProgressHUD dismiss];
        } else {
            [SVProgressHUD showInfoWithStatus:msg];
        }
    }];
}

- (void)startApplyInfo: (LeaderibleModel *)product {
    if (self.isGoLoaning) {
        return;
    }
    self.isGoLoaning = YES;
    
    [[UPLocationManager sharedManager] upRequestLocationPermissionWithCompletion:^(BOOL granted) {
        if ([AppConfig sharedInstance].appCountryEnv == AppCountryEnvIndonesia) {
            if (!granted) {
                self.isGoLoaning = NO;
                return;
            }
        }
        
        [self fetchApplyInfo:product];
        // 上报位置信息
        [[UPLocationManager sharedManager] upGetFullLocationInfoWithCompletion:^(UPLocationInfo info) {
            [UPReportDataManager reportLocationInfoWithLocationInfo:info];
        }];
        
        // 上报设备信息
        [UPReportDataManager reportDeviceInfo];
        double startTime = [UPUserDefaults doubleForKey:loginStartTimeKey];
        double endTime = [UPUserDefaults doubleForKey:loginEndTimeKey];
        if (startTime && endTime) {
            [UPReportDataManager reportToMaiDian:UPSceneTypeSignIn
                                       productId:nil
                                      productNum:nil
                                  startTimeStamp:startTime
                                    endTimeStamp:endTime];
        }
    }];
}

- (void)fetchApplyInfo: (LeaderibleModel *)product {
    [SVProgressHUD show];
    NSString *pid = [NSString stringWithFormat:@"%@", product.degreeaneous];
    __block typeof(self) weakSelf = self;
    [UPStocksAPIManager fetchApplyWithProductId:pid completion:^(ProductApplyModel * _Nullable model, NSString * _Nullable msg) {
        self.isGoLoaning = NO;
        if (model) {
            
            if (model.acuial) {
                [weakSelf showFuDaiAlertView: model.acuial];
            } else if (model.pontstudyesque != nil && model.pontstudyesque.length > 0) {
                NSString *urlStr = model.pontstudyesque ;
                if ([urlStr hasPrefix:@"http"] || [urlStr hasPrefix:@"https"]) {
                    [weakSelf pushToWebViewController:urlStr order:NO];
                } else {
                    [[UPSchemeManager shared] parser:urlStr];
                }
            } else {
                [weakSelf pushToApplyDetailVC:product];
            }
            [SVProgressHUD dismiss];
        } else {
            [SVProgressHUD showInfoWithStatus:msg];
        }
    }];
}

- (void)commonInitSubviews {
    [self.view addSubview:self.bottomBgImageView];
    [self.bottomBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.equalTo(self.view);
        make.top.equalTo(self.view).offset(267);
    }];
    
    __weak typeof(self) weakSelf = self;
    self.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [weakSelf fetchData];
    }];
    
    if ([self.scrollView.mj_header isKindOfClass:[MJRefreshNormalHeader class]]) {
        MJRefreshNormalHeader *header = (MJRefreshNormalHeader *)self.scrollView.mj_header;
        
        [header setTitle:@"" forState:MJRefreshStateIdle];
        [header setTitle:@"" forState:MJRefreshStatePulling];
        [header setTitle:@"" forState:MJRefreshStateRefreshing];
        header.lastUpdatedTimeLabel.hidden = YES;
        header.stateLabel.hidden = YES;
    }
    
    [self.view addSubview:self.scrollView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.equalTo(self.view);
        make.top.equalTo(self.view).offset(60);
        make.bottom.equalTo(self.view).offset(-mainTabBarHeight);
    }];
    
    [self.scrollView addSubview:self.containerView];
    [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.equalTo(self.scrollView);
        make.width.equalTo(self.scrollView);
    }];
    
    [self.containerView addSubview:self.activityTopView];
    CGFloat topViewHeight = [self.activityTopView getTopViewHeight];
    [self.activityTopView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.equalTo(self.scrollView).inset(20);
        make.top.equalTo(self.scrollView);
        make.height.mas_equalTo(topViewHeight);
    }];
    
    [self.containerView addSubview:self.handImgView];
    [self.handImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.scrollView);
        make.top.equalTo(self.activityTopView.mas_bottom).offset(-60);
        make.width.mas_equalTo(83);
        make.height.mas_equalTo(78);
    }];
    [self.containerView addSubview:self.chooseUsImgView];
    [self.containerView addSubview:self.quickLoanImgView];
    [self.containerView addSubview:self.customerServiceBtn];
    [self.containerView addSubview:self.repaymentView];
    [self.containerView addSubview:self.productListView];
}

- (void)setLargeCardLayout {
    
    if ([AppConfig sharedInstance].appCountryEnv == AppCountryEnvIndonesia) {
        self.chooseUsImgView.hidden = YES;
        self.quickLoanImgView.hidden = YES;
        self.customerServiceBtn.hidden = YES;
    } else {
        self.chooseUsImgView.hidden = NO;
        self.quickLoanImgView.hidden = NO;
        self.customerServiceBtn.hidden = NO;
    }
    self.productListView.hidden = YES;
    self.repaymentView.hidden = YES;
    
    [self.chooseUsImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.handImgView.mas_bottom).offset(20);
        make.leading.trailing.equalTo(self.scrollView).inset(20);
        make.height.mas_equalTo([self getImageHeight:[UIImage imageNamed:@"choose_us"]]);
    }];
    
    [self.quickLoanImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.chooseUsImgView.mas_bottom).offset(15);
        make.leading.trailing.equalTo(self.chooseUsImgView);
        make.height.mas_equalTo([self getImageHeight:[UIImage imageNamed:@"quick_loan_steps"]]);
    }];
    
    [self.customerServiceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.quickLoanImgView.mas_bottom).offset(15);
        make.leading.trailing.equalTo(self.chooseUsImgView);
        make.height.mas_equalTo([self getImageHeight:[UIImage imageNamed:@"customer_service"]]);
        if ([AppConfig sharedInstance].appCountryEnv == AppCountryEnvIndonesia) {
        } else {
            make.bottom.equalTo(self.containerView).offset(-10);
        }
    }];
    
    if ([AppConfig sharedInstance].appCountryEnv == AppCountryEnvIndonesia) {
        [self.containerView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.leading.trailing.equalTo(self.scrollView);
            make.height.mas_equalTo(600);
        }];
    }
    
    [self.view setNeedsLayout];
    [self.view layoutIfNeeded];
    self.scrollView.contentSize = self.containerView.frame.size;
}

- (void)setSmallCardLayout {
    self.chooseUsImgView.hidden = YES;
    self.quickLoanImgView.hidden = YES;
    self.customerServiceBtn.hidden = YES;
    self.productListView.hidden = NO;
    self.repaymentView.hidden = NO;
    
    [self.repaymentView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.handImgView.mas_bottom).offset(10);
        make.leading.trailing.equalTo(self.view).inset(42);
        make.height.mas_equalTo(50);
    }];
    
    CGFloat height = [self.productListView getTableViewListHeight];
    [self.productListView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.repaymentView.mas_bottom).offset(10);
        make.leading.trailing.equalTo(self.view);
        make.height.mas_equalTo(height);
        make.bottom.equalTo(self.containerView);
    }];
    
    [self.containerView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.equalTo(self.scrollView);
        make.width.equalTo(self.scrollView);
    }];

    [self.view setNeedsLayout];
    [self.view layoutIfNeeded];
    self.scrollView.contentSize = self.containerView.frame.size;
}

- (CGFloat)getImageHeight: (UIImage *)image {
    CGFloat quickRatio = 1.0;
    if (image.size.width > 0 && image.size.height > 0) {
        quickRatio = image.size.width / image.size.height;
    }
    
    CGFloat width = kScreenWidth - 2 * 20;
    CGFloat height = width / quickRatio;
    return height;
}

- (void)setRepaymentView {
    if (self.repaymentCircumibility.leaderible.count > 0) {
        self.repaymentView.hidden = NO;
    } else {
        self.repaymentView.hidden = YES;
        [self.repaymentView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
    [self.repaymentView updateWithDatas:self.repaymentCircumibility.leaderible];
}

-(void)pushToApplyDetailVC:(LeaderibleModel *)product  {
    if ([[UIApplication up_currentViewController] isKindOfClass:[UPGoToApplyViewController class]]) {
        return;
    }
    UPGoToApplyViewController *vc = [[UPGoToApplyViewController alloc] init];
    vc.productId = product.degreeaneous;
    [[UIApplication up_currentViewController].navigationController pushViewController:vc animated:true];
}

-(void)pushToWebViewController: (NSString *)url order: (BOOL)isFollowOrder {
    if ([[UIApplication up_currentViewController] isKindOfClass:[UPWebViewController class]]) {
        return;
    }
    UPWebViewController *webVC = [[UPWebViewController alloc] init];
    webVC.urlString = url;
    webVC.isFollowOrder = isFollowOrder;
    [[UIApplication up_currentViewController].navigationController pushViewController:webVC animated:YES];
}

- (void)showFuDaiAlertView: (Acuial *)acuial {
    UPCustomAlertView *alert = [[UPCustomAlertView alloc] initWithBackgroundImage:[UIImage imageNamed:@"alert_bg_image1"]
                                                                           style:UPAlertViewStyleCenter];
    [alert setTitle:acuial.musetic
              font:[UIFont boldSystemFontOfSize:13]];

    [alert setContent:acuial.enneasome
                font:[UIFont systemFontOfSize:13]];
    for (int i = 0; i < acuial.cath.count; i++) {
        Cath *cath = acuial.cath[i];
        UPButtonStyle buttonStyle = UPButtonStyleDestructive;
        if (i == 0) {
            buttonStyle = UPButtonStyleDefault;
        }
        
        [alert addButtonWithTitle:cath.oesophagous
                            style:UPButtonStyleDestructive
                          handler:^{
            
            
            if (cath.pontstudyesque != nil && cath.pontstudyesque.length > 0) {
                NSString *urlStr = cath.pontstudyesque ;
                if ([urlStr hasPrefix:@"http"] || [urlStr hasPrefix:@"https"]) {
                    [self pushToWebViewController:urlStr order:NO];
                } else {
                    [[UPSchemeManager shared] parser:urlStr];
                }
            }
        }];
    }
    
    // 显示弹窗
    [alert showInView:[UIApplication up_currentKeyWindow]];
}

#pragma mark - lazy
- (UIImageView *)bottomBgImageView {
    if (!_bottomBgImageView) {
        _bottomBgImageView = [[UIImageView alloc] init];
        _bottomBgImageView.image = [UIImage imageNamed:@"home_bottom_bg"];
        _bottomBgImageView.layer.contentsRect = CGRectMake(0, 0, 1, 0.7);
    }
    return  _bottomBgImageView;
}

- (UIScrollView *)scrollView {
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc] init];
        _scrollView.directionalLockEnabled = YES;
        _scrollView.alwaysBounceVertical = YES;
        _scrollView.alwaysBounceHorizontal = NO;
        _scrollView.showsVerticalScrollIndicator = NO;
        _scrollView.userInteractionEnabled = YES;
    }
    return _scrollView;
}

- (UIView *)containerView {
    if (!_containerView) {
        _containerView = [[UIView alloc] init];;
    }
    return _containerView;
}

- (UIImageView *)chooseUsImgView {
    if (!_chooseUsImgView) {
        _chooseUsImgView = [[UIImageView alloc] init];
        _chooseUsImgView.image = [UIImage imageNamed:@"choose_us"];
        _chooseUsImgView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _chooseUsImgView;
}

- (UIImageView *)quickLoanImgView {
    if (!_quickLoanImgView) {
        _quickLoanImgView = [[UIImageView alloc] init];
        _quickLoanImgView.image = [UIImage imageNamed:@"quick_loan_steps"];
        _quickLoanImgView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _quickLoanImgView;
}

- (UIImageView *)handImgView {
    if (!_handImgView) {
        _handImgView = [[UIImageView alloc] init];
        _handImgView.image = [UIImage imageNamed:@"hand_icon"];
        _handImgView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _handImgView;
}

- (UIButton *)customerServiceBtn {
    if (!_customerServiceBtn) {
        _customerServiceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_customerServiceBtn setBackgroundImage:[UIImage imageNamed:@"customer_service"] forState:UIControlStateNormal];
        [_customerServiceBtn addTarget:self action:@selector(clickCustomerAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _customerServiceBtn;
}

- (UPActivityProductListView *)productListView {
    if (!_productListView) {
        _productListView = [[UPActivityProductListView alloc] init];
        _productListView.delegate = self;
    }
    return _productListView;
}

- (UPRepaymentCarouselView *)repaymentView {
    if (!_repaymentView) {
        _repaymentView = [[UPRepaymentCarouselView alloc] init];
        _repaymentView.delegate = self;
    }
    return _repaymentView;
}

#pragma mark - UPInfiniteScrollViewDelegate
- (void)carouselView:(UPRepaymentCarouselView *)carouselView didSelectItemAtIndex:(NSInteger)index data:(LeaderibleModel *)data {
    
    NSString *url = data.pontstudyesque;
    if ([url hasPrefix:@"http"] || [url hasPrefix:@"https"]) {
        [self pushToWebViewController:url order:false];
    } else {
        [[UPSchemeManager shared] parser:url];
    }
}

#pragma mark - UPActivityProductListViewDelegate
- (void)productListViewDidSelectProduct: (LeaderibleModel *)product {
    NSLog(@"点击产品 %@", product.degreeaneous);
    [self startApplyInfo:product];
}

#pragma mark - UPActivityTopViewDelegate
- (void)activityTopViewDidClick {
    [self startApplyInfo:self.bannerProductCircumibility.leaderible.firstObject];
}

#pragma mark -Action

- (void)clickCustomerAction {
    NSString *url = [NSString stringWithFormat:@"%@%@", kH5Domain, @"growthaneous"];
    [self pushToWebViewController:url order:false];
}

-(void)handleLogOutOrExpiredAction: (NSNotification *)notification {
    if (_hasPresentLoginVC) {
        return;
    }
    UPLoginViewController *loginVC = [[UPLoginViewController alloc] init];
    loginVC.modalPresentationStyle = UIModalPresentationFullScreen;
    UIViewController *currentVC = [UIApplication up_currentViewController];
    _hasPresentLoginVC = YES;
    __block typeof(self) weakSelf = self;
    [currentVC presentViewController:loginVC animated:YES completion:^{
        weakSelf.hasPresentLoginVC = NO;
    }];
}

-(void)followUpMyOrderAction: (NSNotification *)notification {

    NSDictionary *userInfo = notification.userInfo;
    OmniosityModel *omniosity = userInfo[@"followUpData"];
    NSString *productId = omniosity.degreeaneous;
    [self fetchProductDetailWitProductId:productId];
}

- (void)fetchProductDetailWitProductId: (NSString *)productId {
    [SVProgressHUD show];
    __block typeof(self) weakSelf = self;
    [UPStocksAPIManager fetchMyLoanDetailWithProductId:productId completion:^(LoanDetailModel * _Nullable model, NSString * _Nullable msg) {
        if (model) {
            [self handleProductDetail:model];
        } else {
            [SVProgressHUD showInfoWithStatus:msg];
        }
        [weakSelf.scrollView.mj_header endRefreshing];
    }];
}

- (void)handleProductDetail:(LoanDetailModel *) loanDetailModel {
    if (loanDetailModel.miasmaistic) { // 有下一步
        [SVProgressHUD dismiss];
        NSString *vcName = loanDetailModel.miasmaistic.saccular;
        NSString *titleName = loanDetailModel.miasmaistic.musetic;
        if ([vcName isEqualToString:@"noct"]) {
            [self pushToAuthVC:loanDetailModel
                     omniosity:loanDetailModel.omniosity
                     titleName:titleName
                        vcName:vcName];
        } else if ([vcName isEqualToString:@"athroidlike"]) {
            [self pushToPersonalVC:loanDetailModel
                         omniosity:loanDetailModel.omniosity
                         titleName:titleName
                            vcName:vcName];
        } else if ([vcName isEqualToString:@"acerbitude"]) {
            [self pushToContactVC:loanDetailModel
                        omniosity:loanDetailModel.omniosity
                        titleName:titleName
                           vcName:vcName];
        } else if ([vcName isEqualToString:@"per"]) {
            [self pushToBankVC:loanDetailModel
                     omniosity:loanDetailModel.omniosity
                     titleName:titleName
                        vcName:vcName];
        }
    } else {

        double startTime = [NSDate date].timeIntervalSince1970;
        [UPStocksAPIManager fetchFollowUpMyProduct:loanDetailModel.omniosity completion:^(FollowLapidant * _Nonnull lapidant, NSString * _Nonnull msg) {
            if (lapidant) {
             
                [self pushToWebViewController:lapidant.pontstudyesque order:YES];
                
                double endTime = [NSDate date].timeIntervalSince1970;
                [UPReportDataManager reportToMaiDian:UPSceneTypeStartLoan
                                           productId:loanDetailModel.omniosity.degreeaneous
                                          productNum:loanDetailModel.omniosity.viciacity
                                      startTimeStamp:startTime
                                        endTimeStamp:endTime];
                [SVProgressHUD dismiss];
            } else {
                [SVProgressHUD showInfoWithStatus:msg];
            }
        }];
    }
}

- (void)pushToAuthVC:(LoanDetailModel *)loanDetailModel
           omniosity:(OmniosityModel *)omniosity
           titleName:(NSString *)titleName
           vcName:(NSString *)vcName {
    UPAuthViewController *authVC = [[UPAuthViewController alloc] init];
    authVC.currentOmniosity = omniosity;
    authVC.titleName = titleName;
    authVC.currentLoanDetailModel = loanDetailModel;
    authVC.vcName = vcName;
    [self.navigationController pushViewController:authVC animated:YES];
}

- (void)pushToAuthCompletedVC:(LoanDetailModel *)loanDetailModel
                    omniosity:(OmniosityModel *)omniosity
                    titleName:(NSString *)titleName
                    vcName:(NSString *)vcName {
    UPAuthCompletedViewController *completedVC = [[UPAuthCompletedViewController alloc] init];
    completedVC.currentOmniosity = omniosity;
    completedVC.titleName = titleName;
    completedVC.currentLoanDetailModel = loanDetailModel;
    completedVC.vcName = vcName;
    [self.navigationController pushViewController:completedVC animated:YES];
}

- (void)pushToPersonalVC:(LoanDetailModel *)loanDetailModel
               omniosity:(OmniosityModel *)omniosity
               titleName:(NSString *)titleName
               vcName:(NSString *)vcName {
    UPPersonalViewController *vc = [[UPPersonalViewController alloc] init];
    vc.currentOmniosity = omniosity;
    vc.titleName = titleName;
    vc.currentLoanDetailModel = loanDetailModel;
    vc.vcName = vcName;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)pushToContactVC:(LoanDetailModel *)loanDetailModel
              omniosity:(OmniosityModel *)omniosity
              titleName:(NSString *)titleName
              vcName:(NSString *)vcName {
    UPContactViewController *vc = [[UPContactViewController alloc] init];
    vc.currentOmniosity = omniosity;
    vc.titleName = titleName;
    vc.currentLoanDetailModel = loanDetailModel;
    vc.vcName = vcName;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)pushToBankVC:(LoanDetailModel *)loanDetailModel
           omniosity:(OmniosityModel *)omniosity
           titleName:(NSString *)titleName
           vcName:(NSString *)vcName {
    UPYINHANGViewController *vc = [[UPYINHANGViewController alloc] init];
    vc.currentOmniosity = omniosity;
    vc.titleName = titleName;
    vc.currentLoanDetailModel = loanDetailModel;
    vc.vcName = vcName;
    [self.navigationController pushViewController:vc animated:YES];
}

@end

